#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "./Message/message.h"
#include "./Maininterface/maininterface.h"
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QDebug>
#include <QSqlError>
#include <QMutex>
#include <QSqlDatabase>
#include <QSql>


QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    Message* message;
    Maininterface* maininterface;
    QWidget* parent;

private slots:
    void on_pushButton_clicked();

    void on_pushButton_2_clicked();

public:
    Ui::MainWindow *ui;
    QSqlDatabase db;
//    QSqlQuery* query;

    // 指定要检查的文件路径
    QString filePath = "database.db";

    QMutex mutex;


public:
    static MainWindow& getInstance() {
        static MainWindow instance;
        return instance;
    }

    QSqlQuery createQuery() {
        QMutexLocker locker(&mutex); // 锁定互斥锁以确保线程安全
        return QSqlQuery(db);
    }
};
#endif // MAINWINDOW_H
